package com.example.controller;

import com.example.pojo.Topic;
import com.example.service.TopicService;
import com.example.service.impl.TopicServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
public class TopicController {
    @Resource(name = "topicService")
    public TopicService topicService;

    @RequestMapping("/index/hotlist")
    @ResponseBody
    public List<Map<String,Object>> getHotTopicList() {
        return topicService.getHotTopicList();
    }

    @RequestMapping("/index/newlist")
    @ResponseBody
    public List<Map<String,Object>> getNewTopicList() {
        return topicService.getNewTopicList();
    }

    @RequestMapping("/index/nicelist")
    @ResponseBody
    public List<Map<String,Object>> getNiceTopicList() {
        return topicService.getNiceTopicList();
    }

    @RequestMapping("/specificlist")
    @ResponseBody
    public List<Map<String,Object>> getSpecificTypeList(String type) {
        return topicService.getSpecificTypeList(type);
    }

    @RequestMapping("/goodtopic")
    @ResponseBody
    public List<Map<String,Object>> getGoodTopicList(String goodType) {
        return topicService.getGoodTopicList(goodType);
    }

    @RequestMapping("/commentlist")
    @ResponseBody
    public List<Map<String,Object>> getCommentList(Integer tId) {
        return topicService.getCommentList(tId);
    }

    @RequestMapping("/searchlist")
    @ResponseBody
    public List<Map<String,Object>> getSearchList(String words) {
        return topicService.getSearchList(words);
    }

    @RequestMapping("/islike")
    @ResponseBody
    public Boolean selectIsLike(Integer uId,Integer tId) {
        return topicService.selectIsLike(uId, tId);
    }

    @RequestMapping("/savelike")
    @ResponseBody
    public Integer saveLike(Integer uId,Integer tId,Boolean isLike) {
        return topicService.saveLike(uId,tId,isLike);
    }

    @RequestMapping("/iscollection")
    @ResponseBody
    public Boolean selectIsCollection(Integer uId,Integer tId) {
        return topicService.selectIsCollection(uId, tId);
    }

    @RequestMapping("/savecollection")
    @ResponseBody
    public Integer saveCollection(Integer uId,Integer tId,Boolean isCollection) {
        return topicService.saveCollection(uId,tId,isCollection);
    }

    @RequestMapping("/inserttopic")
    @ResponseBody
    public Integer insertTopic(Integer uId,String title,String type,String realStatus,String content) {
        return topicService.insertTopic(uId,title,type,realStatus,content);
    }


}
